package com.ruoyi.project.oms.paeaAuAuditFifldInfo.controller;

import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.oms.paeaAuAuditFifldInfo.domain.PaeaAuAuditFifldInfo;
import com.ruoyi.project.oms.paeaAuAuditFifldInfo.service.IPaeaAuAuditFifldInfoService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import java.util.Arrays;

import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 预警头信息Controller
 *
 * @author gang.wei
 * @date 2020-03-24
 */
@Controller
@RequestMapping("/oms/paeaAuAuditFifldInfo")
public class PaeaAuAuditFifldInfoController extends BaseController
{
    private String prefix = "oms/paeaAuAuditFifldInfo";

    @Autowired
    private IPaeaAuAuditFifldInfoService paeaAuAuditFifldInfoService;

    @RequiresPermissions("oms:paeaAuAuditFifldInfo:view")
    @GetMapping()
    public String paeaAuAuditFifldInfo()
    {
        return prefix + "/paeaAuAuditFifldInfo";
    }

    /**
     * 查询预警头信息列表
     */
    @RequiresPermissions("oms:paeaAuAuditFifldInfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PaeaAuAuditFifldInfo paeaAuAuditFifldInfo)
    {
        startPage();
        List<PaeaAuAuditFifldInfo> list = paeaAuAuditFifldInfoService.list(new QueryWrapper<>(paeaAuAuditFifldInfo));
        return getDataTable(list);
    }

    /**
     * 导出预警头信息列表
     */
    @RequiresPermissions("oms:paeaAuAuditFifldInfo:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(PaeaAuAuditFifldInfo paeaAuAuditFifldInfo)
    {
        List<PaeaAuAuditFifldInfo> list = paeaAuAuditFifldInfoService.list(new QueryWrapper<>(paeaAuAuditFifldInfo));
        ExcelUtil<PaeaAuAuditFifldInfo> util = new ExcelUtil<PaeaAuAuditFifldInfo>(PaeaAuAuditFifldInfo.class);
        return util.exportExcel(list, "paeaAuAuditFifldInfo");
    }

    /**
     * 新增预警头信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存预警头信息
     */
    @RequiresPermissions("oms:paeaAuAuditFifldInfo:add")
    @Log(title = "预警头信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PaeaAuAuditFifldInfo paeaAuAuditFifldInfo)
    {
        return toAjax(paeaAuAuditFifldInfoService.saveOrUpdate(paeaAuAuditFifldInfo));
    }

    /**
     * 修改预警头信息
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        PaeaAuAuditFifldInfo paeaAuAuditFifldInfo = paeaAuAuditFifldInfoService.getById(id);
        mmap.put("paeaAuAuditFifldInfo", paeaAuAuditFifldInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存预警头信息
     */
    @RequiresPermissions("oms:paeaAuAuditFifldInfo:edit")
    @Log(title = "预警头信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PaeaAuAuditFifldInfo paeaAuAuditFifldInfo)
    {
        return toAjax(paeaAuAuditFifldInfoService.saveOrUpdate(paeaAuAuditFifldInfo));
    }

    /**
     * 删除预警头信息
     */
    @RequiresPermissions("oms:paeaAuAuditFifldInfo:remove")
    @Log(title = "预警头信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(paeaAuAuditFifldInfoService.removeByIds(Arrays.asList(ids.split(","))));
    }
}
